package com.entity;

import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.handler.CharArrayTypeHandler;
import com.handler.UserSetHandler;
import com.ymx.darling.bean.annotation.Column;
import com.ymx.darling.bean.annotation.Entity;
import com.ymx.darling.bean.annotation.Id;
import com.ymx.darling.bean.entity.id.IdType;
import com.ymx.darling.executor.mapping.relation.annotation.RelationManyToMany;
import com.ymx.darling.executor.mapping.relation.annotation.RelationOneToMany;
import com.ymx.darling.executor.mapping.relation.annotation.RelationOneToOne;
import com.ymx.darling.mask.Mask;
import lombok.Data;
import lombok.experimental.FieldNameConstants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Date;
import java.util.List;


/**
 * @author 爱Java的小于
 */
@Data
@Entity(table = "user")
@FieldNameConstants
public class User {
	@Id(value = IdType.SEQUENCE, keySequence = "user_seq")
	private String id;
	private String userName;
	private String userSex;
	private int userAge;
	private String userAddress;
	private String userPhone;
	private String userPolitical;
	@Column(isLogicDelete = true)
	private int logic;
	@Column(value = "t_id", tenantId = true)
	private int tenantId;
	private String classesId; // 班级id
	private Date createTime; // 创建时间
	private Date updateTime; // 更新时间

	@RelationOneToMany(targetField = Orders.Fields.userId, condition = "t_id != #{tId}")
	private List<Orders> orderList;

	@RelationManyToMany(
			joinTable = "user_role",
			joinSelfColumn = "user_id",
			joinTargetColumn = "role_id",
			targetClass = Role.class,
			selectColumns = "roleName"
	)
	private List<String> roleNames;

	@RelationOneToOne(selfField = Fields.classesId, selectColumns = Classes.Fields.cName, targetClass = Classes.class)
	private String className;
}